﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using SZSLSystem.Model;
namespace SZSLSystem.BLL
{
	/// <summary>
	///业务逻辑类 Room (create by HC 2013/1/14 22:28:42)
	/// </summary>
	public class Room
	{
		private readonly SZSLSystem.DAL.Room dal=new SZSLSystem.DAL.Room();
		public Room(){}
		public bool Exists(string OID)
		{
			 return dal.Exists(OID);
		}

		public int Delete(string OID)
		{
			 return dal.Delete(OID);
		}

		public int Add(SZSLSystem.Model.Room model)
		{
			 return dal.Add(model);
		}

		public SZSLSystem.Model.Room GetModel(string OID)
		{
			 return dal.GetModel(OID);
		}

		public int Update(SZSLSystem.Model.Room model)
		{
			 return dal.Update(model);
		}

		public DataSet GetList(string strWhere)
		{
			 return dal.GetList(strWhere);
		}

		public DataSet GetList(int Top,string strWhere,string fieldOrder)
		{
			 return dal.GetList(Top,strWhere,fieldOrder);
		}

		public DataSet GetList(string showFields,string strWhere)
		{
			 return dal.GetList(showFields,strWhere);
		}

		public List<SZSLSystem.Model.Room> GetModelList(string strWhere)
		{
			 DataSet ds = dal.GetList(strWhere);
			 return DataTableToList(ds.Tables[0]);
		}

		public List<SZSLSystem.Model.Room> DataTableToList(DataTable dt)
		{
			List<SZSLSystem.Model.Room> modelList = new List<SZSLSystem.Model.Room>();
			if (dt.Rows.Count > 0)
			{
				SZSLSystem.Model.Room model;
				foreach (DataRow row in dt.Rows)
				{
					model = new SZSLSystem.Model.Room();
					model.OID=row["OID"].ToString();
					model.WendyOID=row["WendyOID"].ToString();
					if (row["Modules"].ToString()!="")
					{
						model.Modules=int.Parse(row["Modules"].ToString());
					}
					if (row["Layer"].ToString()!="")
					{
						model.Layer=int.Parse(row["Layer"].ToString());
					}
					model.LayerHight=row["LayerHight"].ToString();
					model.RoomNumer=row["RoomNumer"].ToString();
					model.VerandaState=row["VerandaState"].ToString();
					model.HouseType=row["HouseType"].ToString();
					model.HouseTypeImage=row["HouseTypeImage"].ToString();
					model.UnitPrice=row["UnitPrice"].ToString();
					model.ConcessionaRate=row["ConcessionaRate"].ToString();
					model.FloorArea=row["FloorArea"].ToString();
					model.InsideArea=row["InsideArea"].ToString();
					model.PublicArea=row["PublicArea"].ToString();
					model.DecorationType=row["DecorationType"].ToString();
					model.Sitting=row["Sitting"].ToString();
					model.RoomState=row["RoomState"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		public object GetSingle(string fieldName,string strWhere)
		{
			 return dal.GetSingle(fieldName,strWhere);
		}
	}
}